﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace KSOAPlus
{
    public partial class UserInfo : Form
    {
        public UserInfo()
        {
            InitializeComponent();
            rightcopy.Text = Common.rightcopy;
        }
        Common Init = new Common();
        MsSqlHelper mssql = new MsSqlHelper();
        

        private void btnquery_Click(object sender, EventArgs e)
        {
            try
            {
                string search = txtSearch.Text;
                DataTable dt = mssql.ExecuteDt("select rtrim(dzyid) as dzyid,rtrim(dzycode) as dzycode,rtrim(dzyname) as dzyname,rtrim(lgnname) as lgnname,rtrim(kl) as kl,rtrim(kl) as 口令明文,rtrim(beactive) as beactive,rtrim(is_czy) as is_czy from [zhiydoc](nolock) where beactive='是' and is_czy='是' and (dzycode like '%" + search + "%' or lgnname like '%" + search + "%' or dzyname like '%" + search + "%' or zjm like '%" + search + "%' )");                               
                for(int r=0;r<dt.Rows.Count;r++){
                    if (!string.IsNullOrEmpty(dt.Rows[r]["kl"].ToString()))
                    {
                        dt.Rows[r]["口令明文"] = Common.Decrypt(dt.Rows[r]["kl"].ToString());
                    }
                }
                for (int i = 0; i < dt.Columns.Count; i++)
                {
                    string ColumnName = mssql.GetString("select top 1 rtrim(chnname) chnname  from [fldlist] where fdname=rtrim('" + dt.Columns[i].ToString() + "')");
                    if (!dt.Columns.Contains(ColumnName) && !string.IsNullOrEmpty(ColumnName))
                    {
                        dt.Columns[i].ColumnName = ColumnName;
                    }
                }            
                dGV.DataSource = dt;
            }
            catch (Exception ex)
            {
                Init.WriteLog(ex.ToString(), true);
                MessageBox.Show(ex.Message);
            }
        }
    }
}
